<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <title>Document</title>
</head>

<body>

    <div id="app">
        <p>{{msg | msgFormat('rng') | test}}</p>
    </div>

    <script>
        // 定义一个过滤器
        Vue.filter('msgFormat', function (msg, arg) {
            // 字符串的replace方式，第一个参数，除了可写一个字符串之外，还可以定义一个正则表达式
            return msg.replace(/ig/g, arg)
        })
        Vue.filter('test', function (msg) {
            return msg + '=========='
        })

        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'ig上单theshy ig中单rookie'
            },
            methods: {

            }
        })
    </script>
</body>

</html>